import { baseRequestClient, requestClient } from '#/api/request';

export namespace Issue {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date | null;
    remark: string;
    params: Params;
    issueId: number;
    issueCode: string;
    issueName: string;
    workstationId: null | number;
    workstationCode: null | string;
    workstationName: null | string;
    workorderId: number;
    workorderCode: string;
    taskId: null;
    taskCode: null;
    clientId: number;
    clientCode: string;
    clientName: string;
    clientNick: null;
    requiredTime: Date;
    issueDate: Date;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total?: number;
    rows?: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getIssueTableList = (params: Issue.GetListParams) =>
  requestClient.get<Issue.GetListReturn>('/mes/wm/issueheader/list', {
    params,
  });
// 增加生产领料
export const addIssue = (data: Issue.Row) =>
  requestClient.post<Issue.GetListReturn>('/mes/wm/issueheader', data);

// 删除生产领料
export const deleteIssue = (id: string) =>
  requestClient.delete<Issue.GetListReturn>(`/mes/wm/issueheader/${id}`);

// 修改生产领料
export const updateIssue = (data: Issue.Row) =>
  requestClient.put<Issue.GetListReturn>('/mes/wm/issueheader', data);

export const getIssueCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/ISSUE_CODE');

export const issueheader = (id: string) =>
  requestClient.put<Issue.GetListReturn>(`/mes/wm/issueheader/${id}`);
